const jwt = require('jsonwebtoken');

function verifyToken(req, res, next) {
    const token = req.headers['authorization'].split(' ')[1];

    jwt.verify(token, "XXZJXLOVEFDX", (error, payload) => {
        if (error) {
            return res.status(403).send({
                message: 'Forbidden'
            });
        }
    
        req.user = payload;
        
        return next();
    })
    console.log("JWT Token Passed");
  
}

module.exports = verifyToken;
